home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
impressario
/
src
/
libimp
/
impSwap.c.z
/
impSwap.c
Wrap
C/C++ Source or Header
|
1996-05-06
|
3KB
|
116 lines
/**************************************************************************
*
* Copyright (c) 1993 Silicon Graphics, Inc.
* All Rights Reserved
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
*
* The copyright notice above does not evidence any actual of intended
* publication of such source code, and is an unpublished work by Silicon
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is
* the property of Silicon Graphics, Inc. Any use, duplication or
* disclosure not specifically authorized by Silicon Graphics is strictly
* prohibited.
*
* RESTRICTED RIGHTS LEGEND:
*
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
* Technical Data and Computer Software clause at DFARS 52.227-7013,
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR
* Supplement. Unpublished - rights reserved under the Copyright Laws of
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N.
* Shoreline Blvd., Mountain View, CA 94039-7311
**************************************************************************
*
* File: impSwap.c
*
* Description: Internal routines for byte swapping.
*
**************************************************************************/
#ident "$Revision: 1.2 $"
#include <stdio.h>
#include <sys/types.h>
#include "impI.h"
/**************************************************************************
*
* Function: _impSwapHeader
*
* Description: Swaps the bytes of the disk archived portion
* of the image header. The archived portion is the public
* portion.
*
* Parameters:
* image (I) - pointer to an image header
*
* Return: none
*
**************************************************************************/
void _impSwapHeader(IMPImage *image)
{
_impSwapShorts((ushort_t*)(&image->imagic), 6 * sizeof(ushort_t));
_impSwapLongs((__uint32_t*)(&image->min), 3 * sizeof(ulong_t));
_impSwapLongs((__uint32_t*)(&image->colormap), sizeof(ulong_t));
}
/**************************************************************************
*
* Function: _impSwapShorts
*
* Description: Swaps the bytes on an array of shorts.
*
* Parameters:
* arr (I) - array of shorts whose bytes are to be swapped
* nBytes (I) - number of bytes in array (i.e. 2 * narr)
*
* Return: none
*
**************************************************************************/
void _impSwapShorts(register ushort_t *arr, int nBytes)
{
register int i;
register int nShorts = nBytes >> 1;
register ushort_t swd;
for (i = 0; i < nShorts; i++) {
swd = *arr;
*arr++ = _impSwapShort(swd);
}
}
/**************************************************************************
*
* Function: _impSwapLongs
*
* Description: Swaps the bytes on an array of longs.
*
* Parameters:
* arr (I) - array of longs whose bytes are to be swapped
* nBytes (I) - number of bytes in array (i.e. 4 * narr)
*
* Return: none
*
**************************************************************************/
void _impSwapLongs(register __uint32_t *arr, int nBytes)
{
register int i;
register int nLongs = nBytes >> 2;
register __uint32_t lwd;
for (i = 0; i < nLongs; i++) {
lwd = *arr;
*arr++ = _impSwapLong(lwd);
}
}